package com.zzq.my.jetpacks.jectpackapp.net.loadindexdata

import com.zzq.my.jetpacks.jectpackapp.bean.LoadIndexInfo
import com.zzq.my.jetpacks.jectpackapp.net.ApiService
import com.zzq.my.jetpacks.jectpackapp.net.ApiUrl
import com.zzq.my.jetpacks.net.base.BaseRepository
import com.zzq.my.jetpacks.net.base.RetrofitClient
import com.zzq.my.jetpacks.net.entity.ApiResponse
import rxhttp.RxHttp
import rxhttp.awaitResult
import rxhttp.onErrorReturnItem
import rxhttp.toResponse

/**
 * 描述：class describe
 * 作者：zhuangzeqin
 * 时间: 2021/11/25-15:43
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class LoadIndexDataRepo : BaseRepository() {
    private val mApiService by lazy {
        RetrofitClient.getInstance().create(ApiService::class.java)
    }

    suspend fun reqLoadIndexData(): ApiResponse<LoadIndexInfo?> {
        return executeHttp { mApiService.reqLoadIndexData() }
    }

    suspend fun reqLoadIndexDataRxHttp():Result<LoadIndexInfo>
    {
        return RxHttp.get(ApiUrl.LOADINDEXDATA).toResponse<LoadIndexInfo>().awaitResult()
    }

//    suspend fun reqLoadIndexDataRxHttp():LoadIndexInfo
//    {
//        return RxHttp.get(ApiUrl.LOADINDEXDATA).toResponse<LoadIndexInfo>().onErrorReturnItem(LoadIndexInfo()).await()
//    }
}